< Prev(J) / Next(K) > / View :

Filename: /text/sbasic/shared/03090201.xhp

(section: doloop) (bookmark: bm_id3156116)
Do...Loop statement
While; Do loop
Until
loops

Do... Loop ステートメント
While; Doloop
Until
loops

Do...Loop Statement [Runtime]
Do...Loop ステートメント [実行時](hd_id3156116.1)

Repeats the statements between the Do and the Loop statement while the condition is True or until the condition becomes True.
Do ステートメントから Loop ステートメントの間に配置されたステートメントブロックを、判定条件が True である間ないし True になるまでの間、繰り返し実行します。(par_id3109850.2)

(/section: doloop)

Syntax
構文(hd_id3149119.3)

Do [{While | Until} condition = True]
Do [{While | Until} condition = True](par_id3155150.4)

statement block
ステートメントブロック(par_id3154422.5)

[Exit Do]
[Exit Do](par_id3150789.6)

statement block
ステートメントブロック(par_id3155805.7)

Loop
Loop(par_id3145090.8)

or
ないしは(par_id3154749.9)

Do
Do(par_id3150503.10)

statement block
ステートメントブロック(par_id3149762.11)

[Exit Do]
[Exit Do](par_id3150984.12)

statement block
ステートメントブロック(par_id3143228.13)

Loop [{While | Until} condition = True]
Loop [{While | Until} condition = True](par_id3149235.14)

Parameters/Elements
パラメータおよび要素(hd_id3156024.15)

Condition: A comparison, numeric or string expression, that evaluates either True or False.
Condition: True ないし False として評価可能な比較条件あるいは、数値ないし文字列表式。(par_id3156344.16)

Statement block: Statements that you want to repeat while or until the condition is True.
ステートメントブロック: 判定条件が True である間ないしは、True になるまでの間に繰り返し実行するステートメント群。(par_id3149669.17)

The Do...Loop statement executes a loop as long as, or until, a certain condition is True. The condition for exiting the loop must be entered following either the Do or the Loop statement. The following examples are valid combinations:
Do...Loop ステートメントのループは、判定条件が True である間ないしは、True になるまでの間、繰り返し実行されます。ループ終了の判定条件は、Do ないし Loop ステートメントのいずれかに続けて指定する必要があります。判定条件の指定法は、下記の例を参照してください。(par_id3150791.18)

Syntax
構文(hd_id3154366.19)

Do While condition = True
Do While 判定条件 = True(par_id3145171.20)

...statement block
...ステートメントブロック(par_id3149203.21)

Loop
Loop(par_id3125864.22)

The statement block between the Do While and the Loop statements is repeated so long as the condition is true.
この場合、Do While から Loop ステートメントまでの間にあるステートメントブロックは、判定条件が True である限り、繰り返し実行されます。(par_id3154124.24)

Do Until condition = True
Do Until 判定条件 = True(par_id3153968.25)

...statement block
...ステートメントブロック(par_id3154909.26)

Loop
Loop(par_id3159151.27)

The statement block between the Do Until and the Loop statements is repeated if the condition so long as the condition is false.
この場合、Do Until から Loop ステートメントまでの間にあるステートメントブロックは、判定条件が False である限り、繰り返し実行されます。(par_id3150440.29)

Do
Do(par_id3153952.30)

...statement block
...ステートメントブロック(par_id3147349.31)

Loop While condition = True
Loop While 判定条件 = True(par_id3159153.32)

The statement block between the Do and the Loop statements repeats so long as the condition is true.
この場合、Do から Loop ステートメントまでの間にあるステートメントブロックは、判定条件が True である限り、繰り返し実行されます。(par_id3146985.34)

Do
Do(par_id3150488.35)

...statement block
...ステートメントブロック(par_id3153189.36)

Loop Until condition = True
Loop Until 判定条件 = True(par_id3155411.37)

The statement block between the Do and the Loop statements repeats until the condition is true.
この場合、Do から Loop ステートメントまでの間にあるステートメントブロックは、判定条件が True となるまでの間、繰り返し実行されます。(par_id3151117.39)

Use the Exit Do statement to unconditionally end the loop. You can add this statement anywhere in a Do...Loop statement. You can also define an exit condition using the If...Then structure as follows:
ループを無条件に終了させるには、Exit Do ステートメントを使用します。このステートメントは、Do...Loop ステートメントの間の任意の位置に記述できます。また下記の例のように、ループの終了条件に If...Then を使用することもできます。(par_id3149484.41)

Do...
Do...(par_id3149262.42)

statements
ステートメント群(par_id3149298.43)

If condition = True Then Exit Do
If condition = True Then Exit Do(par_id3145646.44)

statements
ステートメント群(par_id3154490.45)

Loop...
Loop...(par_id3153159.46)

Example
(hd_id3147396.47)

Sub ExampleDoLoop
Sub ExampleDoLoop(par_id3144764.49)

Dim sFile As String
Dim sFile As String(par_id3154791.50)

Dim sPath As String
Dim sPath As String(par_id3149401.51)

sPath = "c:\"
sPath = "c:\"(par_id3155600.52)

sFile = Dir$( sPath ,22)
SFile = Dir$( sPath ,22)(par_id3150717.53)

If sFile <> "" Then
If sFile <> "" Then(par_id3146898.54)

Do
Do(par_id3156333.55)

MsgBox sFile
MsgBox sFile(par_id3153947.56)

sFile = Dir$
SFile = Dir$(par_id3150327.57)

Loop Until sFile = ""
Loop Until sFile = ""(par_id3150749.58)

End If
End If(par_id3153765.59)

End Sub
End Sub(par_id3148914.60)


< Prev / Next >